package com.itheima.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.RoleDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.SmallPageBean;
import com.itheima.pojo.Role;
import com.itheima.service.RoleService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = RoleService.class)
@Transactional
public class RoleServiceImpl implements RoleService{


    @Autowired
    private RoleDao roleDao;
    @Override
    public void add(Role role) {

    }

    @Override
    public PageResult findAll(SmallPageBean smallPageBean) {

        Integer smallCurrentPage = smallPageBean.getSmallCurrentPage();
        //每页显示的条数
        Integer smallPageSize = smallPageBean.getSmallPageSize();

        //分页插件助手
        PageHelper.startPage(smallCurrentPage,smallPageSize);
        Page<Role> checkGroups = roleDao.findAll();

        //总条数
        long total = checkGroups.getTotal();
        //所有的ID
        List result = checkGroups.getResult();
        return new PageResult(total,result);
    }


}
